package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

class zadm {
   protected ArrayList a;
   protected com.aspose.cells.a.d.zb b;
   protected zasn c;
   protected com.aspose.cells.b.a.b.zt d = new com.aspose.cells.b.a.b.zt();
   protected com.aspose.cells.b.a.b.zq e = new com.aspose.cells.b.a.b.zq();
   public double[] f = new double[]{1.0D, 1.0D};
   public int g;
   public int h;
   private Workbook i;
   private com.aspose.cells.a.d.ze j;

   public zadm(com.aspose.cells.a.d.zb var1, zasn var2, zbmg var3, PageSetup var4, int var5, int var6, Workbook var7, double var8, double var10, com.aspose.cells.a.d.ze var12) {
      this.j = var12;
      this.a = new ArrayList();
      this.a();
      this.b = var1;
      this.c = var2;
      this.g = var5;
      this.h = var6;
      this.i = var7;
      if (var4.isHFScaleWithDoc()) {
         this.f = var3.c;
      }

      float var13;
      if (var4.isHFAlignMargins()) {
         var13 = (float)var4.getLeftMarginInch() * 72.0F;
      } else {
         var13 = 54.0F;
      }

      float var14 = Math.max((float)var4.getHeaderMarginInch() * 72.0F, 1.0F);
      float var16 = Math.max((float)var4.getFooterMarginInch() * 72.0F, 1.0F);
      float var15;
      if (var4.isHFAlignMargins()) {
         var15 = (float)var4.getRightMarginInch() * 72.0F;
      } else {
         var15 = 54.0F;
      }

      com.aspose.cells.b.a.b.zo var17 = new com.aspose.cells.b.a.b.zo(var13, var14);
      com.aspose.cells.b.a.b.zt var18 = new com.aspose.cells.b.a.b.zt((float)(var8 * 72.0D - (double)var13 - (double)var15), (float)(var10 * 72.0D - (double)var14 - (double)var16));
      this.e = new com.aspose.cells.b.a.b.zq(var17, var18);
   }

   public void a() {
      com.aspose.cells.b.a.a.ze.a(this.a, (Object)(new zadl()));
   }

   private com.aspose.cells.b.a.b.zt c() {
      com.aspose.cells.b.a.b.zt var1 = com.aspose.cells.b.a.b.zt.a();

      zadl var3;
      for(Iterator var2 = this.a.iterator(); var2.hasNext(); var1.b(var1.c() + var3.a)) {
         var3 = (zadl)var2.next();
         if (var1.b() < var3.b) {
            var1.a(var3.b);
         }
      }

      return var1;
   }

   public void a(zot var1) throws Exception {
      zadl var2 = (zadl)this.a.get(this.a.size() - 1);
      boolean var3 = zar.b(var1.a);
      if (!var3 && !zar.a(var1.a)) {
         var2.a(new zadp(var1, this.j));
         this.d = this.c();
      } else {
         zcm var4 = new zcm();
         ArrayList var5 = var4.a(var1, var3);
         Iterator var6 = var5.iterator();

         while(var6.hasNext()) {
            zot var7 = (zot)var6.next();
            var7.b.setName("Times New Roman");
            var2.a(new zadp(var7, this.j));
         }

         this.d = this.c();
      }
   }

   public void a(com.aspose.cells.b.a.d.zh var1, com.aspose.cells.b.a.b.zt var2) {
      zadl var3 = (zadl)this.a.get(this.a.size() - 1);
      var3.a(new zadk(var1, var2));
      this.d = this.c();
   }

   public void b() throws Exception {
      float var1 = 0.0F;
      float var2 = 0.0F;
      switch(this.h) {
      case 0:
         var2 = this.e.m() - this.d.c();
         break;
      case 9:
         var2 = this.e.k();
      }

      zadl var4;
      for(Iterator var3 = this.a.iterator(); var3.hasNext(); var2 += var4.a) {
         var4 = (zadl)var3.next();
         switch(this.g) {
         case 1:
            var1 = this.e.j() + (this.e.h() / 2.0F - var4.b / 2.0F);
            break;
         case 7:
            var1 = this.e.j();
            break;
         case 8:
            var1 = this.e.l() - var4.b;
         }

         com.aspose.cells.a.d.zb[] var5 = new com.aspose.cells.a.d.zb[]{this.b};
         var4.a(var5, new com.aspose.cells.b.a.b.zo(var1, var2));
         this.b = var5[0];
      }

   }
}
